<template>
	<u-navbar class="nav" :title="title" :leftIconSize="36" bgColor="#ffffff" leftIconColor="#fff"
		:titleStyle="titleStyle">
		<view class="u-nav-slot" slot="left">
			<u-icon name="arrow-left" size="44" color='#fff' @tap="toBack(backUrl)"></u-icon>
			<u-line v-if="showHome" direction="column" color='#fff' :hairline="false" length="0"
				margin="0 15rpx"></u-line>
			<u-icon v-if="showHome" name="home" color='#fff' size="48" @tap="toHome"></u-icon>
		</view>
	</u-navbar>
</template>

<script>
	export default {
		options: {
			styleIsolation: 'shared'
		},
		props: {
			title: {
				typeof: String,
				default: ''
			},
			showHome: {
				typeof: Boolean,
				default: true
			},
			backUrl: {
				typeof: String,
				default: ''
			}
		},
		data() {
			return {
				titleStyle: {
					fontSize: '36rpx',
					fontWeight: "bold",
					color: "#777"
				},
				tabUrls: [
					'/pages/index/index',
					'/pages/touristMap/index',
					'/pages/oneCodePass/index',
					'/pages/service/index',
					'/pages/my/index'
				]
			}
		},
		methods: {
			toBack(url) {
				console.log(url, 'url');
				if (!url) {
					let canNavBack = getCurrentPages();
					if (canNavBack && canNavBack.length > 1) uni.navigateBack();
					else uni.redirectTo({
						url
					});
				} else {
					if (this.tabUrls.find(u => u == url)) uni.reLaunch({
						url
					});
					else uni.redirectTo({
						url
					});
				}
			},
			toHome() {
				uni.reLaunch({
					url: '/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss">
	::v-deep .u-nav-slot {
		display: flex;
		padding: 8rpx 16rpx;
		width: 150rpx;
		background-color: transparent;
		border-radius: 30rpx;
		color: #777;
	}


	.nav {
		color: #777;
		background-color: transparent;
	}

	.u-navbar__content {
		color: #777 !important;
		background-color: transparent !important;
	}

	.u-status-bar {
		color: #777 !important;
		background-color: transparent !important;
	}

	.u-navbar__content__title {
		color: #777 !important;
	}
</style>